package com.wanpinghui.supplier.object;

import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Color;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Handler;
import android.os.Message;
import android.support.v4.content.ContextCompat;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextPaint;
import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan;
import android.text.style.ForegroundColorSpan;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.wanpinghui.supplier.R;
import com.wanpinghui.supplier.common.BaseActivity;
import com.wanpinghui.supplier.message.MessageP2PActivity;
import com.wanpinghui.supplier.object.adapter.BidRecordAdapter;
import com.wanpinghui.supplier.object.adapter.FollowRecordAdapter;
import com.wanpinghui.supplier.object.adapter.ObjectDynamicAdapter;
import com.wanpinghui.supplier.object.view.OfferView;
import com.wanpinghui.supplier.user.MinePackageActivity;
import com.wanpinghui.supplier.user.MinePackageActivity2;
import com.wanpinghui.supplier.utils.ActivityJumpUtil;
import com.wanpinghui.supplier.utils.WTimeUtil;
import com.wanpinghui.supplier.widgets.NormalNameValueItem;
import com.wanpinghui.supplier.widgets.RotateTextView;
import com.wanpinghui.supplier.widgets.TitlePanelLayout;
import com.wanpinghui.wphlibrary.WPHSdk;
import com.wanpinghui.wphlibrary.common.ServerResponseStatus;
import com.wanpinghui.wphlibrary.common.UrlConstants;
import com.wanpinghui.wphlibrary.common.dialog.BaseDialogManager;
import com.wanpinghui.wphlibrary.common.dialog.LoadingDialog;
import com.wanpinghui.wphlibrary.common.dialog.YunBaseDialog;
import com.wanpinghui.wphlibrary.common.toast.ToastManager;
import com.wanpinghui.wphlibrary.model.base.AudioPlayManager;
import com.wanpinghui.wphlibrary.model.oauth.OAuthService;
import com.wanpinghui.wphlibrary.model.oauth.bean.UserBean;
import com.wanpinghui.wphlibrary.model.object.ObjectService;
import com.wanpinghui.wphlibrary.model.object.bean.DemandBean;
import com.wanpinghui.wphlibrary.model.object.bean.GetParticipationListResult;
import com.wanpinghui.wphlibrary.model.object.bean.ObjectDetailBean;
import com.wanpinghui.wphlibrary.model.object.bean.ParticipationBean;
import com.wanpinghui.wphlibrary.model.object.constant.DemandType;
import com.wanpinghui.wphlibrary.model.object.constant.ObjectStatus;
import com.wanpinghui.wphlibrary.model.object.constant.ParticipationStatus;
import com.wanpinghui.wphlibrary.widgets.ThrottleButton;
import com.yunshl.yunshllibrary.utils.NumberUtil;
import com.yunshl.yunshllibrary.utils.TextUtil;
import com.yunshl.yunshllibrary.utils.TimeUtil;

import org.xutils.common.util.DensityUtil;
import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.ViewInject;

import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import retrofit.callback.FailOrExceptionType;
import retrofit.callback.YRequestCallback;

/***
 * 功能描述:
 * 作者:qiujialiu
 * 时间:2017/11/24
 ***/
@ContentView(R.layout.layout_activity_object_detail)
public class ObjectDetailActivity extends BaseActivity implements OfferView.OnFunctionListener {
    private static final int COUNT_DOWN = 10;
    private static final int FINISH_ACTIVITY = 12;
    private static final int REQUEST_RECHARGE = 11;
    private static final int HIDE_REFRESH = 15;
    @ViewInject(R.id.tpl_title)
    private TitlePanelLayout mLayoutTitle;
    @ViewInject(R.id.tv_charge_explain)
    private TextView mTextViewChargeExplain;
    @ViewInject(R.id.item_budget)
    private NormalNameValueItem mItemBudget;//预算
    @ViewInject(R.id.ll_first)
    private LinearLayout ll_first;
    @ViewInject(R.id.tv_content)
    private TextView tv_content;
    @ViewInject(R.id.item_location)
    private NormalNameValueItem mItemLocation;
    @ViewInject(R.id.tv_customer_demand)
    private TextView mTextViewDemand;
    @ViewInject(R.id.tv_screen_desc)
    private TextView mTextViewDesception;
    @ViewInject(R.id.item_client_info)
    private NormalNameValueItem mItemCustomer;
    @ViewInject(R.id.item_phone)
    private NormalNameValueItem mItemPhone;
    @ViewInject(R.id.ll_customer_record)
    private LinearLayout mLayoutRecord;
    @ViewInject(R.id.line_record)
    private View mViewLineRecord;
    @ViewInject(R.id.tv_scan_count)
    private TextView mTextViewScanCount;
    @ViewInject(R.id.tv_left_time)
    private TextView mTextViewLeftTime;
    @ViewInject(R.id.lv_bid_record)
    private ListView mListViewBidRecord;
    @ViewInject(R.id.offer_view)
    private OfferView mLayoutOffer;//底部操作按钮
    @ViewInject(R.id.view_partic_record)
    private View mViewParticRecord;
    @ViewInject(R.id.rl_object_dynamic)
    private RelativeLayout mLayoutDynamic;
    @ViewInject(R.id.lv_object_dynamic)
    private RecyclerView mRecyclerViewDynamic;
    @ViewInject(R.id.rl_feedback)
    private RelativeLayout mLayoutFeedBack;
    @ViewInject(R.id.ll_left_time)
    private LinearLayout mLayoutLeftTime;
    @ViewInject(R.id.iv_max_price)
    private ImageView mImageViewMaxPrice;
    @ViewInject(R.id.btn_report)
    private ThrottleButton mButtonReport;
    @ViewInject(R.id.btn_feedback)
    private ThrottleButton mButtonFeedBack;
    @ViewInject(R.id.iv_postmark)
    private ImageView mImageViewPostmark;
    @ViewInject(R.id.iv_play_status_icon)
    private ImageView mImageViewPlay;
    @ViewInject(R.id.tv_record_time)
    private TextView textViewRecordTime;
    @ViewInject(R.id.rl_follow_record)
    private RelativeLayout mLayoutFollow;
    @ViewInject(R.id.tv_publist_count)
    private RotateTextView mTextViewPublishCount;
    @ViewInject(R.id.recv_follow_record)
    private RecyclerView mRecyclerViewFollow;
    @ViewInject(R.id.tv_object_id)
    private TextView mTextViewObjectId;
    @ViewInject(R.id.ll_content)
    private LinearLayout mLayoutContent;
    @ViewInject(R.id.ll_load_fail)
    private LinearLayout mLayoutFail;
    @ViewInject(R.id.tv_reload)
    private TextView mTextViewReload;
    @ViewInject(R.id.srl)
    private SwipeRefreshLayout refreshLayout;
    @ViewInject(R.id.tv_max_price_tip)
    private TextView textViewMaxPriceTip;
    @ViewInject(R.id.view_bid_regulation)
    private View mViewBidRegulation;
    @ViewInject(R.id.view_send_regulation)
    private View mViewSendRegulation;
    @ViewInject(R.id.tv_send_attach_tip)
    private TextView mTextViewSendAttachTip;
    @ViewInject(R.id.tv_cate_title)
    private TextView tv_cate_title;
    //  维修-竞拍规则
    @ViewInject(R.id.object_bid_regulation_tv1)
    private TextView tv_regulation_one;
    @ViewInject(R.id.object_bid_regulation_tv2)
    private TextView tv_regulation_two;
    @ViewInject(R.id.tv_rule)
    private TextView tv_regulation_three;


    private ObjHandler mHandler;
    private ObjectDetailBean objectDetail;
    private long objectId;
    private BidRecordAdapter mParticAdapter;
    private ObjectDynamicAdapter mDynamicAdapter;
    private FollowRecordAdapter mFollowAdapter;
    private boolean loadingPartic;//获取竞价都列表当中（防止网络不好时，重复获取）
    private UserBean mUserBean;
    private long leftTime;//竞价剩余时间
    private long contectLeftTime;//联系剩余时间
    private int timeCount;//计时器
    private boolean loadingShowing;//分配中弹窗显示中
    private int audioDuration = -1;//录音时长
    private boolean isStop;
    private int lastObjectPosition;//列表位置，更新列表当前项目
    private boolean haveShowDialog;//是否已显示过提醒联系弹窗
    private boolean firstLoad = true;//是否是首次加载数据
    private boolean notification;//是否由通知过来


    @Override
    public String getName() {
        return null;
    }

    @Override
    public boolean isBar() {
        return false;
    }

    @Override
    public void initViews() {
        if (getIntent() != null) {
            objectId = getIntent().getLongExtra("id", 0);
            lastObjectPosition = getIntent().getIntExtra("position", -1);
            notification = getIntent().getBooleanExtra("notification", false);
            if (objectId == 0) {
                finish();
            }
        }
        mViewParticRecord.setVisibility(View.GONE);
        mHandler = new ObjHandler(this);
        mParticAdapter = new BidRecordAdapter(this);
        mDynamicAdapter = new ObjectDynamicAdapter(this);
        mListViewBidRecord.setAdapter(mParticAdapter);
        mRecyclerViewDynamic.setLayoutManager(new LinearLayoutManager(this));
        mRecyclerViewDynamic.setAdapter(mDynamicAdapter);
        mFollowAdapter = new FollowRecordAdapter(this);
        mRecyclerViewFollow.setLayoutManager(new LinearLayoutManager(this));
        mRecyclerViewFollow.setAdapter(mFollowAdapter);
    }

    @Override
    public void bindEvents() {
        mLayoutTitle.setOnClickBacktrack(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        mLayoutTitle.setOnClickAddition(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                goP2PChat();
            }
        });

        refreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                getData();
            }
        });

        mLayoutOffer.setFunctionListener(this);


        mImageViewMaxPrice.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                showOfferMaxPriceDialog();
            }
        });

        mTextViewReload.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                refreshLayout.setRefreshing(true);
                mLayoutFail.setVisibility(View.GONE);
                getData();
            }
        });
    }

    @Override
    public void initData() {
        setChargeExplain();
        refreshLayout.post(new Runnable() {
            @Override
            public void run() {
                refreshLayout.setRefreshing(true);
            }
        });
        getData();
        mHandler.sendEmptyMessageDelayed(COUNT_DOWN, 1000);
    }

    private void getData() {
        mUserBean = WPHSdk.getService(OAuthService.class).getUserInfo(null);
        WPHSdk.getService(ObjectService.class)
                .getObjectDetail(objectId, new YRequestCallback<ObjectDetailBean>() {
                    @Override
                    public void onSuccess(ObjectDetailBean var1) {
                        mHandler.sendEmptyMessage(HIDE_REFRESH);
                        showFailView(false);
                        refreshLayout.setRefreshing(false);
                        if (lastObjectPosition >= 0) {
                            Intent intent = new Intent();
                            intent.putExtra("result", JSONObject.toJSONString(var1));
                            intent.putExtra("position", lastObjectPosition);
                            setResult(RESULT_OK, intent);
                        }
                        setData(var1);
                        getParticipationList();
                    }

                    @Override
                    public void onFailed(int var1, String message) {
                        mHandler.sendEmptyMessage(HIDE_REFRESH);
                        if (firstLoad) {
                            showFailView(true);
                        } else {
                            showWarningText(message);
                        }
                    }

                    @Override
                    public void onException(Throwable var1) {
                        mHandler.sendEmptyMessage(HIDE_REFRESH);
                        refreshLayout.setRefreshing(false);
                        var1.printStackTrace();
                        if (firstLoad) {
                            showFailView(true);
                        } else {
                            showWarningText(var1.getMessage());
                        }
                    }
                });
    }

    private void showFailView(boolean isFail) {
        if (isFail) {
            mLayoutContent.setVisibility(View.GONE);
            mLayoutFail.setVisibility(View.VISIBLE);
            mLayoutOffer.setVisibility(View.GONE);
        } else {
            firstLoad = false;
            mLayoutContent.setVisibility(View.VISIBLE);
            mLayoutFail.setVisibility(View.GONE);
            mLayoutOffer.setVisibility(View.VISIBLE);
        }
    }

    private void getParticipationList() {
        loadingPartic = true;
        WPHSdk.getService(ObjectService.class)
                .getParticList(objectId, new YRequestCallback<GetParticipationListResult>() {
                    @Override
                    public void onSuccess(GetParticipationListResult var1) {
                        setParticRecordData(var1);
                        if (var1.getDemand_status() != ObjectStatus.STATUS_ALLOTTING) {
                            mHandler.removeMessages(FINISH_ACTIVITY);
                        }
                    }

                    @Override
                    public void onFailed(int var1, String message) {
                        loadingPartic = false;
                        if (loadingShowing) {
                            mHandler.sendEmptyMessageDelayed(FINISH_ACTIVITY, 10000);
                        }
                    }

                    @Override
                    public void onException(Throwable var1) {
                        loadingPartic = false;
                        var1.printStackTrace();
                        if (loadingShowing) {
                            mHandler.sendEmptyMessageDelayed(FINISH_ACTIVITY, 10000);
                        }
                    }
                });
    }

    private void setParticRecordData(GetParticipationListResult var1) {
        if (objectDetail.getCurrentStatus() == 15) {
            if (var1.getPartic_supplier_list() != null && var1.getPartic_supplier_list().size() > 0) {
                ParticipationBean bean = var1.getPartic_supplier_list().get(0);
                String contentStr = "";
                if (mUserBean != null && mUserBean.getUser() != null && mUserBean.getUser().getId().equals(bean.getId())) {
                    contentStr = "我  " + bean.getOffer() + "汇币 暂时领先";
                    //tv_content.setText("我  " + bean.getOffer() + "汇币");
                } else {
                    contentStr = bean.getHide_nickname() + "  " + bean.getOffer() + "汇币 暂时领先";
                    //tv_content.setText(bean.getHide_nickname() + "  " + bean.getOffer() + "汇币");
                }
                SpannableString spannableString = new SpannableString(contentStr);
                spannableString.setSpan(new ForegroundColorSpan(ContextCompat.getColor(ObjectDetailActivity.this,R.color.colorPrimaryBlue)),spannableString.length()-5,spannableString.length(),Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
                //  tv_content.setText(var1.getPartic_supplier_list().get(0));
                ll_first.setVisibility(View.VISIBLE);
                tv_content.setText(spannableString);
            } else {
                ll_first.setVisibility(View.GONE);
                tv_content.setText("");
            }
        } else {
            ll_first.setVisibility(View.GONE);
            tv_content.setText("");
        }
        loadingPartic = false;
        if (objectDetail != null) {
            objectDetail.setParticList(var1.getPartic_supplier_list());
            if (objectDetail.getDemand().getStatus() != var1.getDemand_status()) {
                objectDetail.getDemand().setStatus(var1.getDemand_status());
                objectDetail.setSupplier_partic_status(var1.getSupplier_partic_status());
                setData(objectDetail);
                getData();
            } else if (objectDetail.getSupplier_partic_status() != var1.getSupplier_partic_status()) {
                objectDetail.setSupplier_partic_status(var1.getSupplier_partic_status());
                setData(objectDetail);
                getData();
            }
            mParticAdapter.setDatas(var1.getPartic_supplier_list(), objectDetail.getDemand().getStatus());
        }
        mLayoutOffer.setMaxBidCount(var1.getMaxBid());
        mLayoutOffer.setIsMaxPrice(var1.isHas_max());
        if (mParticAdapter.getCount() > 0) {
            mViewParticRecord.setVisibility(View.VISIBLE);
        } else {
            mViewParticRecord.setVisibility(View.GONE);
        }
        if(objectDetail.getDemand().getCate()==2){
            mViewParticRecord.setVisibility(View.GONE);
        }
        mListViewBidRecord.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, mParticAdapter.getCount() * DensityUtil.dip2px(73.5f)));
    }

    private void setChargeExplain() {
        String chargeString = getString(R.string.app_charge_explain);
        SpannableString chargeSpanStr = new SpannableString(chargeString);
        chargeSpanStr.setSpan(new ClickableSpan() {
            @Override
            public void onClick(View widget) {
                Intent intent = new Intent(ObjectDetailActivity.this, MinePackageActivity2.class);
                startActivity(intent);
            }

            @Override
            public void updateDrawState(TextPaint ds) {
                ds.setUnderlineText(false);
            }
        }, chargeString.indexOf("我的账户"), chargeString.indexOf("我的账户") + 4, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        chargeSpanStr.setSpan(new ForegroundColorSpan(ContextCompat.getColor(ObjectDetailActivity.this, R.color.colorPrimaryBlue))
                , chargeString.indexOf("我的账户"), chargeString.indexOf("我的账户") + 4, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        mTextViewChargeExplain.setText(chargeSpanStr);
        mTextViewChargeExplain.setMovementMethod(LinkMovementMethod.getInstance());
    }

    private void setData(ObjectDetailBean bean) {
        this.objectDetail = bean;
        if (bean != null) {
            DemandBean demandBean = objectDetail.getDemand();
            if (justInvalidData(demandBean)) return;
            //设置基础信息
            if (demandBean.getBudget() == 0) {
                mItemBudget.setContent("议价");
            } else {
                mItemBudget.setContent("￥" + NumberUtil.double2StringComma(demandBean.getBudget()));
            }
            mItemLocation.setContentHint(demandBean.getCity() + demandBean.getAddr());
            mTextViewDemand.setText(demandBean.getCateStr());
            if (demandBean.getCate() == DemandType.TYPE_MAINTAIN) {
                mTextViewDemand.setTextColor(ContextCompat.getColor(ObjectDetailActivity.this, R.color.color_7ed321));
            } else if (demandBean.getCate() == DemandType.TYPE_LEASE) {
                mTextViewDemand.setTextColor(ContextCompat.getColor(ObjectDetailActivity.this, R.color.color_f3a536));
            } else {
                mTextViewDemand.setTextColor(ContextCompat.getColor(ObjectDetailActivity.this, R.color.colorPrimaryBlue));
            }
            mTextViewDesception.setText(demandBean.getDescription("，"));
            mItemCustomer.setContentHint(objectDetail.getUser().getNickname());
            if(demandBean.getCate()==2){
                tv_cate_title.setText("故障");
                mTextViewDesception.setText(demandBean.getMalfStr());
                tv_regulation_one.setText("维修订单根据屏幕颜色和故障类型分别定价，单色屏幕8汇币、全彩屏幕20或30汇币。");
                tv_regulation_two.setText("出价成功即可联系客户，无需竞拍，每个订单最多5人获得客户联系方式。");
                tv_regulation_three.setText("如出价成功者5分钟内未能联系客户，名额作废且扣除当次竞拍汇币的30%作为惩罚，并自动通知下一名竞拍者中标。");
            }else {
                tv_cate_title.setText("需求");
                mTextViewDesception.setText(demandBean.getDescription("，"));
            }
            if (demandBean.getMax_bid_point() > 0) {
                mLayoutOffer.maxPrice = demandBean.getMax_bid_point();
                mParticAdapter.setMaxBid(demandBean.getMax_bid_point());
                textViewMaxPriceTip.setText("订单最多出价" + demandBean.getMax_bid_point() + "汇币属于爆灯，多人爆灯成就值高者得。");
            }

            if (objectDetail.getMy_offer() == demandBean.getMax_bid_point()) {
                mImageViewMaxPrice.setVisibility(View.GONE);
            }

            setTimeCountDownView(demandBean);
            if (objectDetail.getCurrentStatus() == 5) {
                mTextViewSendAttachTip.setVisibility(View.VISIBLE);
            } else {
                mTextViewSendAttachTip.setVisibility(View.GONE);
            }
            if (objectDetail.getPartic_demand_status() == 9 || (objectDetail.isIs_training()&&TextUtil.isNotEmpty(objectDetail.getUser().getMobile()))) {
                mViewBidRegulation.setVisibility(View.GONE);
                mViewSendRegulation.setVisibility(View.VISIBLE);
            } else {
                mViewBidRegulation.setVisibility(View.VISIBLE);
                mViewSendRegulation.setVisibility(View.GONE);
            }

            setPostmark();

            mTextViewObjectId.setText("项目ID：34" + demandBean.getId());
            setAudioLayout(demandBean);
            mTextViewScanCount.setText(demandBean.getScan_count() + "人浏览过");
            mLayoutTitle.setTitle(objectDetail.getTitle());
            setFeedBackData(demandBean);
            setDynamicData(demandBean);
            mLayoutOffer.setData(objectDetail);

            //多次发布角标
            if (objectDetail.getFollow_records() != null && objectDetail.getFollow_records().size() > 0) {
                if (demandBean.getPublished_count() >= 2) {
                    mTextViewPublishCount.setVisibility(View.VISIBLE);
                    mTextViewPublishCount.setText(demandBean.getPublished_count() + "次发布");
                }
                mLayoutFollow.setVisibility(View.VISIBLE);
                if (objectDetail.getFollow_records() != null && objectDetail.getFollow_records().size() > 0) {
                    mFollowAdapter.setDatas(objectDetail.getFollow_records());
                }
                //全部取消时，gone
                if(objectDetail.getMy_follow_type() == 3 && mFollowAdapter!=null && mFollowAdapter.isAllCancle()){
                    mLayoutFollow.setVisibility(View.GONE);
                }else {
                    mLayoutFollow.setVisibility(View.VISIBLE);
                }
            } else {
                mLayoutFollow.setVisibility(View.GONE);
                mTextViewPublishCount.setVisibility(View.GONE);
            }
        }
    }

    /**
     * 设置邮戳UI
     */
    private void setPostmark() {
        if (objectDetail.getMy_follow_type() == 1) {
            mImageViewPostmark.setVisibility(View.VISIBLE);
            mImageViewPostmark.setImageResource(R.mipmap.my_icon_djsd);
        } else if (objectDetail.isHas_demand_locked()) {
            mImageViewPostmark.setVisibility(View.VISIBLE);
            mImageViewPostmark.setImageResource(R.mipmap.my_icon_qtrsd);
        } else {
            if (objectDetail.getCurrentStatus() == 1) {
                mImageViewPostmark.setVisibility(View.VISIBLE);
                mImageViewPostmark.setImageResource(R.mipmap.my_icon_ymwc);
            } else if (objectDetail.getCurrentStatus() == 9) {
                mImageViewPostmark.setVisibility(View.VISIBLE);
                mImageViewPostmark.setImageResource(R.mipmap.my_icon_qdjs);
            } else if (objectDetail.getCurrentStatus() == 10) {
                mImageViewPostmark.setVisibility(View.VISIBLE);
                mImageViewPostmark.setImageResource(R.mipmap.my_icon_jbjs);
            } else {
                mImageViewPostmark.setVisibility(View.GONE);
            }
        }
    }

    /**
     * 设置倒计时UI
     *
     * @param demandBean
     */
    private void setTimeCountDownView(DemandBean demandBean) {
        if (objectDetail.getCurrentStatus() == 15    ) {
            mLayoutLeftTime.setVisibility(View.VISIBLE);
            if ((System.currentTimeMillis() / 1000) >= demandBean.getPublished_at()) {
                leftTime = (demandBean.getOngoing_bid_seconds() - (((System.currentTimeMillis() / 1000)) - demandBean.getPublished_at()));
                if (leftTime > 0) {
                    mTextViewLeftTime.setText(TimeUtil.format(leftTime * 1000, "mm分ss秒"));
                } else {
                    mLayoutLeftTime.setVisibility(View.GONE);
                }
            } else {
                mLayoutLeftTime.setVisibility(View.GONE);
            }
        }else if( objectDetail.getCurrentStatus() == 2 ){
            mLayoutLeftTime.setVisibility(View.VISIBLE);
            if ((System.currentTimeMillis() / 1000) >= demandBean.getPublished_at()) {
                leftTime = (demandBean.getOngoing_bid_seconds() - (((System.currentTimeMillis() / 1000)) - objectDetail.getBid_win_at()));
                if (leftTime > 0) {
                    mTextViewLeftTime.setText(TimeUtil.format(leftTime * 1000, "mm分ss秒"));
                } else {
//                    mLayoutTitle.setTitle("超时未联系");
                    mLayoutLeftTime.setVisibility(View.GONE);
                }
            } else {
//                mLayoutTitle.setTitle("超时未联系");
                mLayoutLeftTime.setVisibility(View.GONE);
            }
            if(objectDetail.getSupplier_partic_status() == 200){
                mLayoutLeftTime.setVisibility(View.GONE);
            }
        } else if (objectDetail.getCurrentStatus() == 6 || objectDetail.getCurrentStatus() == 18 || objectDetail.getCurrentStatus() == 5 || objectDetail.getCurrentStatus() == 7) {
            if (objectDetail.getBid_win_at() > 0 && (objectDetail.getSupplier_partic_status() == ParticipationStatus.OFFER_SUCCESS_NO_FUND || objectDetail.getSupplier_partic_status() == ParticipationStatus.OFFER_SUCCESS_NO_ATTACH)) {
                if ((System.currentTimeMillis() / 1000) >= objectDetail.getBid_win_at()) {
                    contectLeftTime = (demandBean.getWin_bid_contact_limit_seconds() - (((System.currentTimeMillis() / 1000)) - objectDetail.getBid_win_at()));
                    if (contectLeftTime > 0) {
                        mLayoutLeftTime.setVisibility(View.VISIBLE);
                        mTextViewLeftTime.setText(TimeUtil.format(leftTime * 1000, "mm分ss秒"));

//                        if (!haveShowDialog && objectDetail.getCurrentStatus() != 5) {
//                            showContectDialog();
//                        }
                    } else {
                        mLayoutLeftTime.setVisibility(View.GONE);
                    }
                } else {
                    mLayoutLeftTime.setVisibility(View.GONE);
                }
            }
        } else {
            mLayoutLeftTime.setVisibility(View.GONE);
        }
    }

    /**
     * 判断项目的有效性
     *
     * @param demandBean
     * @return 是否不再渲染页面
     */
    private boolean justInvalidData(DemandBean demandBean) {
        if (demandBean.getStatus() == ObjectStatus.STATUS_INVALID) {
            setInvalidView();
            return true;
        } else if (demandBean.getStatus() == ObjectStatus.STATUS_ALLOTTING) {
            if (!loadingShowing) {
                loadingShowing = true;
                LoadingDialog.Build(ObjectDetailActivity.this).setContent("分配中").show();
            }
            mHandler.sendEmptyMessageDelayed(FINISH_ACTIVITY, 10000);
        } else {
            mHandler.removeMessages(FINISH_ACTIVITY);
            LoadingDialog.dismissDialog();
            loadingShowing = false;
        }
        return false;
    }

//    private void showContectDialog() {
//        if (objectDetail == null) return;
//        haveShowDialog = true;
//        if (notification) {
//            String message = "已为您接通客户\n" + "注意接听0216的电话";
//            BaseDialogManager.getInstance().getBuilder(ObjectDetailActivity.this)
//                    .setTitle("正在呼叫...")
//                    .setMessage(message)
//                    .setRightButtonText("我知道了")
//                    .setOnClickListener(new DialogInterface.OnClickListener() {
//                        @Override
//                        public void onClick(DialogInterface dialog, int which) {
//                            dialog.dismiss();
//                        }
//                    }).create().showCanceledOnTouchOutside(false);
//        }else {
//            String message = "约5分钟为您接通客户\n" + "注意接听0216的电话";
//            BaseDialogManager.getInstance().getBuilder(ObjectDetailActivity.this)
//                    .setIcon(ContextCompat.getDrawable(this, R.mipmap.toast_icon_ok))
//                    .setTitle("竞拍成功")
//                    .setMessage(message)
//                    .setRightButtonText("我知道了")
//                    .setOnClickListener(new DialogInterface.OnClickListener() {
//                        @Override
//                        public void onClick(DialogInterface dialog, int which) {
//                            dialog.dismiss();
//                        }
//                    }).create().showCanceledOnTouchOutside(false);
//        }
//    }

    private void setInvalidView() {
        BaseDialogManager.getInstance().getBuilder(ObjectDetailActivity.this)
                .setIcon(ContextCompat.getDrawable(this, R.mipmap.toast_icon_mistake))
                .setTitle("无法查看")
                .setMessage("订单已失效")
                .setRightButtonText("我知道了")
                .setOnClickListener(new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                        finish();
                    }
                }).create().showCanceledOnTouchOutside(false);
    }


    //设置反馈与申报UI
    private void setFeedBackData(final DemandBean demandBean) {
        if (objectDetail.getMy_follow_type() == 3 || objectDetail.getCurrentStatus() == 1 || objectDetail.getSupplier_partic_status() == ParticipationStatus.OVERTIME_NO_ATTACH) {
            mLayoutFeedBack.setVisibility(View.GONE);
        } else if (objectDetail.getSupplier_partic_status() == 200) {
            mLayoutFeedBack.setVisibility(View.VISIBLE);
            if (objectDetail.getFeedback_info() != null && objectDetail.getFeedback_info().getFeedback_status() != 0 && !objectDetail.isHas_demand_locked()) {
                if (objectDetail.getFeedback_info().getFeedback_status() == 1) {
                    mButtonFeedBack.setEnabled(false);
                    mButtonFeedBack.setText("审核失败");
                }
                if (objectDetail.getFeedback_info().getFeedback_status() == 3) {
                    mButtonFeedBack.setEnabled(false);
                    mButtonFeedBack.setText("审核中");
                }
                if (objectDetail.getFeedback_info().getFeedback_status() == 2) {
                    mButtonFeedBack.setEnabled(false);
                    mButtonFeedBack.setText("审核通过");
                }
            } else {
                if (objectDetail.isHas_demand_locked() && objectDetail.getMy_follow_type() == 1) {
                    mButtonFeedBack.setEnabled(false);
                    mButtonFeedBack.setText("已锁定");
                } else {
                    mButtonFeedBack.setEnabled(true);
                    mButtonFeedBack.setText("反馈");
                    mButtonFeedBack.setOnThrottleClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            Intent intent = new Intent(ObjectDetailActivity.this, FeedBackActivity.class);
                            intent.putExtra("id", demandBean.getId());
                            intent.putExtra("success_at", objectDetail.getBid_win_at());
                            String descStr = demandBean.getProv() + demandBean.getCity() + objectDetail.getUser().getNickname() + "," + demandBean.getObjectTypeStr() + "项目";
                            descStr = descStr + "(" + demandBean.getDescription("/") + ")";
                            intent.putExtra("desception", descStr);
                            intent.putExtra("dispatch", objectDetail.getPartic_demand_status() == 9);
                            if (objectDetail.isHas_demand_locked() && objectDetail.getMy_follow_type() != 1) {
                                intent.putExtra("lock", false);
                            }
                            startActivityForResult(intent, 10087);
                        }
                    });
                }
            }

            if (objectDetail.getUser_finish_img_info() != null && objectDetail.getUser_finish_img_info().getState() != -1) {
                if (objectDetail.getUser_finish_img_info().getState() == 2) {
                    mButtonReport.setEnabled(false);
                    mButtonReport.setText("审核失败");
                }
                if (objectDetail.getUser_finish_img_info().getState() == 0) {
                    mButtonReport.setEnabled(false);
                    mButtonReport.setText("审核中");
                }
                if (objectDetail.getUser_finish_img_info().getState() == 1) {
                    mButtonReport.setEnabled(false);
                    mButtonReport.setText("审核通过");
                }
            } else {
                mButtonReport.setEnabled(true);
                mButtonReport.setText("申报");
                mButtonReport.setOnThrottleClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Intent intent = new Intent(ObjectDetailActivity.this, ReportActivity.class);
                        intent.putExtra("id", demandBean.getId());
                        startActivityForResult(intent, 10086);
                    }
                });
            }
        } else {
            mLayoutFeedBack.setVisibility(View.GONE);
        }
    }

    //设置项目动态UI
    private void setDynamicData(DemandBean demandBean) {
        List<ObjectDynamicAdapter.ObjectDynamicBean> list = new ArrayList<>();
        if (TextUtil.isNotEmpty(demandBean.getPublish_remark())) {
            Map<String, String> dataMap = new Gson().fromJson(demandBean.getPublish_remark(), new TypeToken<Map<String, String>>() {
            }.getType());
            if (dataMap != null && dataMap.keySet().size() > 0) {
                for (String key : dataMap.keySet()) {
                    ObjectDynamicAdapter.ObjectDynamicBean bean1 = new ObjectDynamicAdapter.ObjectDynamicBean();
                    bean1.content = "【" + key + "次发布】 " + dataMap.get(key);
                    bean1.icon = R.mipmap.discover_icon_mytip;
                    bean1.name = "万屏汇小秘书";
                    bean1.time = demandBean.getPublished_at();
                    list.add(bean1);
                }
            }
        }
        if (TextUtil.isNotEmpty(demandBean.getRemark())) {
            ObjectDynamicAdapter.ObjectDynamicBean bean1 = new ObjectDynamicAdapter.ObjectDynamicBean();
            bean1.content = demandBean.getRemark();
            bean1.icon = R.mipmap.discover_icon_clientele;
            bean1.name = "客户 | " + objectDetail.getUser().getNickname();
            bean1.time = demandBean.getPublished_at();
            list.add(bean1);
        }
        if (demandBean.getCate() == DemandType.TYPE_MAINTAIN) {
            ObjectDynamicAdapter.ObjectDynamicBean bean1 = new ObjectDynamicAdapter.ObjectDynamicBean();
            bean1.content = demandBean.getDescription("，");
            bean1.icon = R.mipmap.discover_icon_clientele;
            bean1.name = "客户 | " + objectDetail.getUser().getNickname();
            bean1.time = demandBean.getPublished_at();
            list.add(bean1);
        }
        if (TextUtil.isNotEmpty(demandBean.getSource())) {
            ObjectDynamicAdapter.ObjectDynamicBean bean1 = new ObjectDynamicAdapter.ObjectDynamicBean();
            String contentStr = "客户来源: " + demandBean.getSource();
            if (TextUtil.isNotEmpty(demandBean.getSem_keyword())) {
                contentStr = contentStr + "\n" + "搜索词: " + demandBean.getSem_keyword();
            }
            bean1.content = contentStr;
            bean1.icon = R.mipmap.discover_icon_mytip;
            bean1.name = "万屏汇小秘书";
            bean1.time = demandBean.getPublished_at();
            list.add(bean1);
        }
        mDynamicAdapter.setDatas(list);
        if (list.size() == 0) {
            mLayoutDynamic.setVisibility(View.GONE);
        } else {
            mLayoutDynamic.setVisibility(View.VISIBLE);
        }
    }


    /**
     * 设置录音UI
     *
     * @param demandBean
     */
    int play_status;

    private void setAudioLayout(final DemandBean demandBean) {
        play_status = 0;
        AudioPlayManager.getInstance().stop();
        if (TextUtil.isEmpty(demandBean.getAudio())) {
            mLayoutRecord.setVisibility(View.GONE);
            mViewLineRecord.setVisibility(View.GONE);
        } else {
            if (!demandBean.isAudio_sensitive()) {
                mLayoutRecord.setVisibility(View.VISIBLE);
                mViewLineRecord.setVisibility(View.VISIBLE);
            } else {
                if (objectDetail.getSupplier_partic_status() == ParticipationStatus.BID_SUCCESS) {
                    mLayoutRecord.setVisibility(View.VISIBLE);
                    mViewLineRecord.setVisibility(View.VISIBLE);
                } else {
                    mLayoutRecord.setVisibility(View.GONE);
                    mViewLineRecord.setVisibility(View.GONE);
                }
            }
        }
        mImageViewPlay.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (play_status == AudioPlayManager.status_playing) {
                    AudioPlayManager.getInstance().pause();
                    mImageViewPlay.setImageResource(R.mipmap.discover_icon_play);
                } else {
                    AudioPlayManager.getInstance().start(demandBean.getAudio(), new AudioPlayManager.OnPlayListener() {
                        @Override
                        public void onStart(MediaPlayer mediaPlayer) {
                            play_status = AudioPlayManager.status_playing;
                            audioDuration = mediaPlayer.getDuration();
                            mImageViewPlay.setImageResource(R.mipmap.discover_icon_suspend);
                            textViewRecordTime.setText(WTimeUtil.getRecordTimeStr(mediaPlayer.getDuration() / 1000));
                        }

                        @Override
                        public void onComplete(MediaPlayer mediaPlayer) {
                            play_status = 0;
                            textViewRecordTime.setText("客户录音");
                            mImageViewPlay.setImageResource(R.mipmap.discover_icon_play);
                        }

                        @Override
                        public void onError(MediaPlayer mediaPlayer) {
                            play_status = 0;
                            showWarningText("播放录音失败 IOException");
                        }

                        @Override
                        public void onPause(MediaPlayer mediaPlayer) {
                            play_status = AudioPlayManager.status_pause;
                            mImageViewPlay.setImageResource(R.mipmap.discover_icon_play);
                        }

                        @Override
                        public void onResume(MediaPlayer mediaPlayer) {
                            play_status = AudioPlayManager.status_playing;
                            mImageViewPlay.setImageResource(R.mipmap.discover_icon_suspend);
                        }
                    });
                }
            }
        });
    }

    /**
     * 出价
     *
     * @param id
     * @param price
     * @param isMax 是否爆灯
     */
    private void offerObject(long id, int price, final boolean isMax) {
        WPHSdk.getService(ObjectService.class)
                .bidObject(id, price, new YRequestCallback<ObjectDetailBean>() {
                    @Override
                    public void onSuccess(ObjectDetailBean var1) {
                        if (isMax) {
                            ToastManager.getInstance().showRichToast(ObjectDetailActivity.this, "出价成功", "若领先者放弃联系客户，您将有机会获得客户信息", R.mipmap.toast_icon_ok);
                        } else {
                            if (var1 != null && var1.getDemand() != null && (var1.getDemand().getStatus() == ObjectStatus.STATUS_BID_SECOND || var1.getDemand().getStatus() == ObjectStatus.STATUS_FREE_BIDDING)) {
                                ToastManager.getInstance().showRichToast(ObjectDetailActivity.this, "出价成功", "若领先者放弃联系客户，您将有机会获得客户信息", R.mipmap.toast_icon_ok);
                            } else {
                                ToastManager.getInstance().showRichToast(ObjectDetailActivity.this, "出价成功", "请保持领先状态，以免出局", R.mipmap.toast_icon_ok);
                            }
                        }
                        setData(var1);
                    }

                    @Override
                    public void onFailed(int var1, String message) {
                        if (var1 == ServerResponseStatus.NOT_ENOUGH_POINT) {
                            BaseDialogManager.getInstance().getBuilder(ObjectDetailActivity.this)
                                    .setTitle("额度不足")
                                    .setMessage("您的汇币已不足，不能参与抢单\n请立即充值。")
                                    .setLeftButtonText("取消")
                                    .setRightButtonText("充值")
                                    .setIcon(ContextCompat.getDrawable(ObjectDetailActivity.this, R.mipmap.dialog_box_icon_hb))
                                    .setOnClickListener(new DialogInterface.OnClickListener() {
                                        @Override
                                        public void onClick(DialogInterface dialog, int which) {
                                            dialog.dismiss();
                                            if (which == BaseDialogManager.RIGHT_BUTTON) {
                                                // TODO: 2017/12/1 充值
                                                Intent intent = new Intent(ObjectDetailActivity.this, MinePackageActivity2.class);
                                                intent.putExtra("result", true);
                                                startActivityForResult(intent, REQUEST_RECHARGE);
                                            }
                                        }
                                    }).create().show();
                        } else if (var1 != FailOrExceptionType.NO_LOGIN) {
                            ToastManager.getInstance().showRichToast(ObjectDetailActivity.this, "出价失败", message, R.mipmap.toast_icon_mistake);
                        }
                    }

                    @Override
                    public void onException(Throwable var1) {
                        var1.printStackTrace();
                    }
                });
    }

    @Override
    public void onOffer(long id, int price, boolean isMax) {
        if (isMax) {
            showOfferMaxPriceDialog();
        } else {
            offerObject(id, price, isMax);
        }
    }

    @Override
    public void seeOther() {
        ActivityJumpUtil.startObjectList(ObjectDetailActivity.this);
    }

    @Override
    public void attach(long id, final String phone, boolean isFirst) {
        if (isFirst) {
            String message = "抢单成功后，系统会自动帮您呼叫客户，请留意接听0216的电话";
            BaseDialogManager.getInstance().getBuilder(ObjectDetailActivity.this)
                    .setTitle("抢单成功，正在呼叫客户")
                    .setMessage(message)
                    .setRightButtonText("我知道了")
                    .setOnClickListener(new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            dialog.dismiss();
                        }
                    }).create().showCanceledOnTouchOutside(false);
        }else {
//            if (UrlConstants.URL.startsWith("https://opc.wanpinghui.com")) {
                BaseDialogManager.getInstance().getBuilder(ObjectDetailActivity.this)
                    .setTitle("联系客户")
                    .setMessage("联系客户时申明来自万屏汇\n可提高成单率哦！")
                    .setRightButtonText("知道了")
//                    .setIcon(ContextCompat.getDrawable(ObjectDetailActivity.this, R.mipmap.dialog_box_icon_hb))
                    .setOnClickListener(new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            dialog.dismiss();
                            if (which == BaseDialogManager.RIGHT_BUTTON) {
                                Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + phone));
                                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                                startActivity(intent);
                            }
                        }
                    }).create().show();
//            } else {
//                WPHSdk.getService(ObjectService.class).callPhone("13929569170", phone, new YRequestCallback() {
//                    @Override
//                    public void onSuccess(Object var1) {
//                        //showWarningText("呼叫成功");
//                    }
//
//                    @Override
//                    public void onFailed(int var1, String message) {
//                        //showWarningText(message);
//                    }
//
//                    @Override
//                    public void onException(Throwable var1) {
//                        var1.printStackTrace();
//                    }
//                });
//            }
        }
    }

    @Override
    public void goMineBalance() {
        startActivity(new Intent(this,MinePackageActivity2.class));

    }

    @Override
    public void freeOffer(long id) {
        offerObject(id, 0, false);
    }

    @Override
    public void showMaxPrice(boolean isMax) {
        if (isMax) {
            mImageViewMaxPrice.setVisibility(View.VISIBLE);
        } else {
            mImageViewMaxPrice.setVisibility(View.GONE);
        }
    }

    @Override
    public void hidePhone(boolean hide) {
        if (hide || TextUtil.isEmpty(objectDetail.getUser().getMobile())) {
            mItemPhone.setContentHint("抢单成功可见");
        } else {
            mItemPhone.setContentHint(objectDetail.getUser().getMobile());
        }
    }

    @Override
    public void setBottomText(String text) {
        if (TextUtil.isNotEmpty(text)) {
            ll_first.setVisibility(View.VISIBLE);
            tv_content.setText(text);
        }else {
            ll_first.setVisibility(View.GONE);
        }
    }

    private static class ObjHandler extends Handler {

        private WeakReference<ObjectDetailActivity> reference;

        public ObjHandler(ObjectDetailActivity activity) {
            reference = new WeakReference<>(activity);
        }

        @Override
        public void handleMessage(Message msg) {
            ObjectDetailActivity activity = reference.get();
            switch (msg.what) {
                case COUNT_DOWN:
                    if (activity != null) {
                        if (activity.objectDetail != null) {
                            //录音播放倒计时处理
                            if (activity.play_status == AudioPlayManager.status_playing) {
                                if (activity.audioDuration > 0) {
                                    activity.audioDuration = activity.audioDuration - 1000;
                                    activity.textViewRecordTime.setText(WTimeUtil.getRecordTimeStr(activity.audioDuration / 1000));
                                } else {
                                    activity.textViewRecordTime.setText("00:00");
                                }
                            } else if (activity.play_status == 0) {
                                activity.textViewRecordTime.setText("客户录音");
                            }
                            activity.timeCount++;
                            //竞价中倒计时处理
                            if (activity.leftTime > 0) {
                                activity.leftTime--;
                                if (activity.leftTime > 0) {
                                    activity.mTextViewLeftTime.setText(TimeUtil.format(activity.leftTime * 1000, "mm分ss秒"));
                                } else {
                                    activity.mTextViewLeftTime.setText("00分00秒");
                                    if (activity.objectDetail.getDemand().getStatus() == ObjectStatus.STATUS_BIDDING) {
                                        if (!activity.loadingShowing) {
                                            LoadingDialog.Build(activity).setContent("分配中").show();
                                            activity.loadingShowing = true;
                                        }
                                        activity.mHandler.removeMessages(11);
                                        activity.mHandler.sendEmptyMessageDelayed(11, 5000);
                                    }
                                }
                            }
                            //请尽快联系倒计时处理
                            if (activity.contectLeftTime > 0) {
                                activity.contectLeftTime--;
                                if (activity.contectLeftTime > 0) {
                                    activity.mTextViewLeftTime.setText(TimeUtil.format(activity.contectLeftTime * 1000, "mm分ss秒"));
                                } else {
                                    activity.mTextViewLeftTime.setText("00分00秒");
                                    if (activity.objectDetail.getDemand().getStatus() == ObjectStatus.STATUS_BIDDING) {
                                        activity.mHandler.removeMessages(11);
                                        activity.mHandler.sendEmptyMessageDelayed(11, 2000);
                                    }
                                }
                            }
                            //每3秒刷新一次竞价人列表
                            if (activity.timeCount % 3 == 0) {
                                if (!activity.loadingPartic && !activity.isStop) {
                                    activity.getParticipationList();
                                }
                            }
                        }
                        if (activity != null) {
                            activity.mHandler.removeMessages(COUNT_DOWN);
                            activity.mHandler.sendEmptyMessageDelayed(COUNT_DOWN, 1000);
                        }
                    }
                    break;
                case 11:
                    if (activity != null) {
                        activity.getData();
                    }
                    break;
                case FINISH_ACTIVITY:
                    if (activity != null) {
                        LoadingDialog.dismissDialog();
                    }
                    break;
                case HIDE_REFRESH:
                    if (activity != null) {
                        activity.refreshLayout.setRefreshing(false);
                    }
                    break;
            }
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mHandler.removeMessages(COUNT_DOWN);
    }

    @Override
    protected void onStart() {
        super.onStart();
        isStop = false;
    }

    @Override
    protected void onStop() {
        super.onStop();
        AudioPlayManager.getInstance().stop();
        isStop = true;
    }


    private void showOfferMaxPriceDialog() {
        BaseDialogManager.getInstance().getBuilder(ObjectDetailActivity.this)
                .setIcon(ContextCompat.getDrawable(ObjectDetailActivity.this, R.mipmap.dialog_box_icon_bd))
                .setTitle("将扣取" + mLayoutOffer.maxPrice + "个汇币")
                .setMessage("最多出" + mLayoutOffer.maxPrice + "汇币\n如多人爆灯，成就值最高者得")
                .setRightButtonText("确认爆灯")
                .setButtonType(YunBaseDialog.Builder.DialogType.TYPE_YELLOW)
                .setOnClickListener(new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                        offerObject(objectId, mLayoutOffer.maxPrice, true);
                    }
                }).create().show();
    }

    //去聊天
    private void goP2PChat() {
        if (objectDetail != null) {
            String title=objectDetail.getDemand().getChatTitleDescription();
            /*if(objectDetail.getDemand().getCate()==2)
                title=objectDetail.getDemand().getMalfStr();*/
            MessageP2PActivity.startHaveTitle(ObjectDetailActivity.this, objectDetail.getUser().getId(),objectDetail.getDemand().getCateStr(),title);
        }
    }


    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if ((requestCode == 10086 || requestCode == 10087) && resultCode == RESULT_OK) {
            getData();
        } else if (requestCode == REQUEST_RECHARGE && resultCode == RESULT_OK) {
            getData();
        }
    }
}
